#pragma once
#include "Common.h"

class B
{
public:
    int _bint = 9;
};

class A
{
public:
    // static const int型可以在类内声明处初始化（int, char, bool）
    static const int _scint = 6;
    static const char _scchar = 'b';
    static const bool _scbool = true;

    static const double _scdouble;
    static const string _scstring;
    static const B _scB;
    int _aint = 7; // C++11为构造函数初始化列表提供缺省值

    A() {}; // 空构造
};

// 若取static const的地址则必须在类外定义
const int A::_scint;

// static const 其他内置类型（非int型）必须在类外定义处初始化（不初始化、不取地址可以不定义）
const double A::_scdouble = 6.25;

// static const 自定义类型必须在类外定义
const string A::_scstring = "abc";
const B A::_scB;


void Test_ConstStatic()
{
    cout << A::_scint << endl;
    cout << A::_scchar << endl;
    cout << A::_scbool << endl;
    cout << &A::_scint << endl;
    cout << A::_scdouble << endl;
    cout << &A::_scdouble << endl;
    // cout << A::_scstring << endl;
    // cout << &A::_scstring << endl;
    cout << A::_scB._bint << endl;
    // cout << &A::_scB._bint << endl;
    A a;
    cout << a._aint << endl;
    cout << &a._aint << endl;
}